package com.user.controller;

import com.common.result.Result;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.user.domain.dto.UserCreateDto;
import com.user.domain.vo.UserVo;
import com.user.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: stefanie-zy
 * @time: 2024/1/25-14:16
 * @description: 用户控制层
 */
@Tag(name = "系统用户接口")
@ApiSort(2)
@RequestMapping(value = "/api-user")
@RequiredArgsConstructor
@RestController
@Slf4j
@ApiSupport(author = "stefanie-zy", order = 1)
public class UserController {

    private final UserService userService;

    @Operation(summary = "新增用户")
    @PostMapping("")
    public Result<UserVo> create(@RequestBody @Validated UserCreateDto dto) {
        userService.duplicationCheck(dto);
        return Result.success(userService.create(dto));
    }
}
